<template>
    <div>
        <div class="toolbar">
            <el-button type="success"
                       @click="goodsListVisible=true"
            >添加员工
            </el-button>
        </div>

        <el-table
                v-loading="$store.state.isLoading"
                :border="true"
                :data="$store.state.goods.goodsList"
                style="width: 100%">
            <el-table-column label="员工ID" width="250">
                <template slot-scope="scope">
                    {{scope.row._id}}
                </template>
            </el-table-column>
        <el-table-column
                label="上传日期"
                width="200">
            <template slot-scope="scope">
                <i class="el-icon-time"></i>
                <span style="margin-left: 10px">{{ scope.row.createTime | date }}</span>
            </template>
        </el-table-column>
        <el-table-column label="姓名">
            <template slot-scope="scope">
                {{scope.row.goodsName}}
            </template>
        </el-table-column>

        <el-table-column label="职位">
            <template slot-scope="scope">
                {{scope.row.goodsTypeName}}
            </template>
        </el-table-column>

        <el-table-column label="照片">
            <template slot-scope="scope">
                <img :src="'/ele/'+scope.row.goodsPic" alt="" width="150px">
            </template>
        </el-table-column>
            <el-table-column label="工资">
                <template slot-scope="scope">
                    {{scope.row.goodsPrice}}
                </template>
            </el-table-column>
        <el-table-column label="操作">
            <template slot-scope="scope">
                <!--<el-button size="mini" type="success" @click="shopTypeId=scope.row._id;shopListVisible=true;">添加商品信息</el-button>-->
                <el-button size="mini" type="danger" @click="deleteOne(scope.row._id)" >删除</el-button>
            </template>
        </el-table-column>
        </el-table>

        <GoodsListDialog v-if="goodsListVisible" :goods-list-visible.sync="goodsListVisible"></GoodsListDialog>
        <PageInfo actions-name="getGoodsList"></PageInfo>
    </div>
</template>

<script>
    export default {
        name: "GoodsList",
        data(){
            return {
                goodsListVisible:false,
            }
        },
        mounted(){
            // this.$store.dispatch("getGoodsList")

                // console.log(111,this.$store.state.goods.goodsList)
        },
        methods:{
            async deleteOne(id){
                const path = this.$route.path
                const data = await this.$store.dispatch("deleteOneById",{id,path})
                if(data.ok ===1)
                    this.$store.dispatch("getGoodsList")
            }
        }
    }
</script>

<style scoped>

</style>